﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

namespace CascadeDropDown.Component
{
    public class MyDropDownList : DropDownList, IMyControl
    {
        public bool ControlEnabled
        {
            get
            {
                return this.Enabled;
            }
            set
            {
                this.Enabled = value;
            }
        }
        public override bool Enabled
        {
            get
            {
                return base.Enabled;
            }
            set
            {
                base.Enabled = value;
            }
        }

        public string BindColumnName
        {
            get;
            set;
        }

        public void setValue(object value)
        {
            if (value == null)
            {
                this.SelectedIndex = -1;
                return;
            }
            if (this.Items.FindByValue(value.ToString()) != null)
            {
                this.SelectedValue = value.ToString();
            }
        }

        public object getValue()
        {
            return string.IsNullOrEmpty(this.SelectedValue) ? null : this.SelectedValue;
        }

        string IMyControl.FormatString
        {
            get;
            set;
        }

    }
}